<%@page import = "lasec.bean.MovieInfoBean" %>
<jsp:useBean id="bean" scope = "request" class = "lasec.bean.MovieInfoBean"></jsp:useBean>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/htm14/loose.dtd">
<%@ include file="header.jsp"%>
	<script>
		function valuecheck() {
			var value;
			for (var i = 0; i < document.data.radio_rate.length; i++) {
				if (document.data.radio_rate[i].checked) {
					value =  document.data.radio_rate[i].value;
				}
			}
			FB.getLoginStatus(function(response) {
				if (response.session) {
					var uid = FB.getSession().uid;
					var param = "uid=" + encodeURIComponent(uid) + "&value=" + encodeURIComponent(value) + "&mid=" + encodeURIComponent(<%=bean.getMovie_Id()%>);
					sendRequest("/LaSeC/Rate", param, AJAXresult, "post");
					return true;
				} else {
					alert("please login");
					return false;
				}
			});
			
		}

	</script>
	<div id="body">
		<div class="container">
			<h3><%=bean.getMovie_title()%></h3>
           	<div id = "left" style=""><br />
				<p><font size = "4">Movie Genre: <%=bean.getMovie_genre()%></font></p>
				<p><font size = "4">Average ratings: <%=bean.getAverage_rating()%></font></p>
				<p><font face="verdana" color="red" size = "3">Please rate a movie. 5 is the highest while 1 is the lowest.
				
				Clicking the Radio button will automatically submit the rating. There is no confirmation.</font></P>
				<form name = "data" method = "post">
					<p>
						<font size = "4">
							Rate: 1<input name="radio_rate" type="radio" value="1" onclick="return valuecheck()"/>
							2<input name="radio_rate" type="radio" value="2" onclick="return valuecheck()"/> 
							3<input name="radio_rate" type="radio" value="3" onclick="return valuecheck()"/> 
							4<input name="radio_rate" type="radio" value="4" onclick="return valuecheck()"/>
							5<input name="radio_rate" type="radio" value="5" onclick="return valuecheck()"/>
						</font>
					</p>
				</form>
			</div>

			<div id = "right">
				<font size = "3">
					<p>Plot summary: </p>
					<% if (bean.getMovie_plot() == null) { %>
						
					<% } else { %>
					<%=bean.getMovie_plot()%>
					<% } %>
                </font>
            </div>
		</div><!-- end container -->
    </div><!-- end of body -->
<%@ include file="footer.jsp"%>